<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | create by allen.qiang
// +----------------------------------------------------------------------


/**
 * 商品秒杀操作功能
 * @package  htdocs
 * @subpackage  quanliadmin
 * @author   create by allen.qiang
 */
require 'module/base/promotionHandler.class.php';
require 'module/base/goodsHandler.class.php';
class pa_goodsSeckill{
    public function execute(){
        global $G_PGLOB;
        switch ($_REQUEST['operFlg']){
            case 1:                 //商品秒杀列表
                $this->seckillList();
                break;
            case 2:                 //商品秒杀添加/编辑
            case 3:
                $this->seckillEdit($_REQUEST['operFlg']);
                break;
            default:
                $G_PGLOB->smarty->assign('error_msg','参数错误');
                $G_PGLOB->smarty->display('comm/errorDisplay.tpl');
                break;
        }
    }

    /**
     * 商品秒杀列表
     */
    private function seckillList(){
        global $G_PGLOB;



        $G_PGLOB->smarty->display('promotion/seckillList.tpl');
    }

    /**
     *商品秒杀添加/编辑
     */
    private function seckillEdit($operFlg){
        global $G_PGLOB;

        //编辑
        if($operFlg == 3){
            if(!isset($_REQUEST['kill_id']) || !is_numeric($_REQUEST['kill_id'])){
                $G_PGLOB->smarty->assign('error_msg','参数错误');
                $G_PGLOB->smarty->display('promotion/seckillEdit.tpl');
                die();
            }

            //促销类
            $promotionHandler = new promotionHandler($G_PGLOB->DBCA);
            $params_array = array('kill_id' => $_REQUEST['kill_id']);
            $result_info = $promotionHandler->searchSeconKillList($params_array);

            if(!$result_info){
                $G_PGLOB->smarty->assign('error_msg','未找到秒杀信息');
                $G_PGLOB->smarty->display('promotion/seckillEdit.tpl');
                die();
            }

            $G_PGLOB->smarty->assign('seckill_array',$result_info[0]);
        }

        //整点时间
        $startTime_array = array();
        for($i = 1; $i < 24; $i++){
            $startTime_array[] = $i < 10 ? "0".$i : $i;
        }
        $G_PGLOB->smarty->assign('startTime_array',$startTime_array);

        $G_PGLOB->smarty->assign('operFlg',$operFlg);

        $G_PGLOB->smarty->display('promotion/seckillEdit.tpl');
    }

}